package com.bestv.search.common.service.impl;

import com.bestv.search.common.dao.SearchKeywordDao;
import com.bestv.search.common.dataSource.DataSourceKey;
import com.bestv.search.common.model.SearchKeyword;
import com.bestv.search.common.service.SearchKeywordManager;

import java.util.List;
import java.util.Map;

/**
 * @author Michael Wang
 */
public class SearchKeywordManagerImpl implements SearchKeywordManager {

    private SearchKeywordDao searchKeywordDao;

    public SearchKeywordDao getSearchKeywordDao() {
        return searchKeywordDao;
    }

    public void setSearchKeywordDao(SearchKeywordDao searchKeywordDao) {
        this.searchKeywordDao = searchKeywordDao;
    }

    @Override
    public void saveSearchKeywordList(DataSourceKey key, List<SearchKeyword> keywordList) {
        searchKeywordDao.saveSearchKeywordList(keywordList);
    }

    @Override
    public Map<String, Integer> sumEachKeyword(DataSourceKey key) {
        return searchKeywordDao.sumEachKeyword();
    }

    @Override
    public void clearKeywords(DataSourceKey key) {
        searchKeywordDao.removeAllKeywords();
    }

    @Override
    public List<SearchKeyword> getSearchKeywords(DataSourceKey key, String keyword) {
        return searchKeywordDao.getSearchKeywords(keyword);
    }

    @Override
    public List<SearchKeyword> getTimeSortedKeywords(DataSourceKey key) {
        return searchKeywordDao.getTimeSortedKeywords();
    }
}
